// Copyright 2017 guangbo. All rights reserved.

//消息命令服务函数配置 gate服务读取，更新小心命令字转发消息
package lib_config

import (
	"gitee.com/goxiang2/server/lib/lib_watch"
	"strconv"
)

const (
	CmdKey = "cmd"
)

func GetAllCmdConfig(client *lib_watch.WatchClient) map[uint32]string {
	m := make(map[uint32]string)
	values := client.Hgetall(CmdKey)
	for i := 0; i < len(values); i = i + 2 {
		n, _ := strconv.Atoi(values[i])
		m[uint32(n)] = values[i+1]
	}
	return m
}

func SetCmdConfig(client *lib_watch.WatchClient, cmd uint32, serviceFunc string) {
	client.Hset(CmdKey, strconv.Itoa(int(cmd)), serviceFunc)
}

func GetCmdConfig(client *lib_watch.WatchClient, cmd uint32) string {
	return client.Hget(CmdKey, strconv.Itoa(int(cmd)))
}
